package cn.com.header.core.web.springmvc;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ModelAttribute;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author Liangzhongqiu
 * @date 2017/3/6 006
 * @time 20:34
 */
public class WebAbstractController {

    protected Logger logger = LoggerFactory.getLogger(getClass());

    protected HttpServletRequest httpRequest;

    protected HttpServletResponse httpResponse;


    @ModelAttribute
    protected void initRequestAndResponse(HttpServletRequest httpRequest, HttpServletResponse httpResponse) {
        this.httpRequest = httpRequest;
        this.httpResponse = httpResponse;
    }

    protected Object getSessionParam(String paramKey) {
        return httpRequest.getSession().getAttribute(paramKey);
    }

    protected void putSessionParam(String paramKey, Object paramValue) {
        httpRequest.getSession().setAttribute(paramKey, paramValue);
    }

}
